#include<bits/stdc++.h>
#define int long long
using namespace std;
int T,a,b,ans;
signed main(){
	freopen("sub.in","r",stdin);
	freopen("sub.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	cin>>T;
	while(T--) {
		cin>>a>>b;
		ans=abs(a+b);
		ans=min(ans,min(abs(a),abs(b)));
		if(a==0||b==0) {
			cout<<"0\n";
			continue ;
		}
		if(a/abs(a)==b/abs(b)) ans=0;
		cout<<ans<<"\n";
	}
	return 0;
}
/*
a b
a-b b
a-b 2b-a
2a-3b 2b-a
3a-5b 2b-a
*/
